#!/usr/bin/python
# author dennis
# 2022年06月14日
import multiprocessing
import time

my_list = []


def write():
    for i in range(3):
        my_list.append(i)
        print("add:%d" % i)
    print("write_data:", my_list)


def read():
    print("read_data:", my_list)


if __name__ == '__main__':
    # 创建写入数据的进程
    write_process = multiprocessing.Process(target=write)
    # 创建读取数据的进程
    read_process = multiprocessing.Process(target=read)

    write_process.start()
    time.sleep(1)
    read_process.start()
    time.sleep(5)

    # 主进程的全局
    print(my_list)